package com.atos.optical.model.bo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wanghra
 * @version 1.0
 * @description 树形结构node
 * @date 2025/8/13
 */
@Data
@Builder
public class TreeNodeBo {
    /**
     * antd id
     */
    private String key;
    /**
     * antd id
     */
    private String value;
    /**
     * antd name
     */
    private String title;
    /**
     * antd name
     */
    private String label;
    /**
     * 类型
     */
    private int type;
    /**
     * url
     */
    private String url;
    /**
     * icon
     */
    private String icon;
    /**
     * 排序
     */
    private int order;
    /**
     * 父级id
     */
    private String parentId;
    /**
     * 其他
     */
    private Object attributes;
    /**
     * 是否展示复选框
     */
    private Boolean checkable;
    /**
     * 禁用checkbox
     */
    private Boolean disableCheckbox;
    /**
     * 是否禁用
     */
    private Boolean disabled;
    /**
     * 是否隐藏
     */
    private Boolean hideFlag;
    /**
     * 是否是叶子节点 默认不配置
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Boolean isLeaf;
    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<TreeNodeBo> children;

    public void addChild(TreeNodeBo tree) {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        this.children.add(tree);
    }

    public void addChildren(List<TreeNodeBo> trees) {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        this.children.addAll(trees);
    }
}
